/**
 * 认证相关API
 * 对接Java后端: /api/mobile/auth
 */

const { post, get } = require('../utils/request');

/**
 * 微信登录
 * POST /api/mobile/auth/wechat/login
 */
function wechatLogin(code, userInfo = {}) {
  return post('/mobile/auth/wechat/login', { 
    code,
    nickname: userInfo.nickname,
    avatar: userInfo.avatar,
    gender: userInfo.gender
  }, { showLoading: true });
}

/**
 * 刷新Token
 * POST /api/mobile/auth/refresh
 */
function refreshToken() {
  return post('/mobile/auth/refresh');
}

/**
 * 获取当前用户信息
 * GET /api/mobile/user/info
 */
function getCurrentUser() {
  return get('/mobile/user/info');
}

/**
 * 更新用户信息
 * PUT /api/mobile/user/info
 */
function updateUserInfo(userInfo) {
  const { put } = require('../utils/request');
  return put('/mobile/user/info', userInfo);
}

module.exports = {
  wechatLogin,
  refreshToken,
  getCurrentUser,
  updateUserInfo
};
